ORACLE_INCL=${ORACLE_HOME}/precomp/public
PROC_INCL= include=${ORACLE_INCL} \
		include=${ORACLE_HOME}/plsql/include \
                include=/usr/include \
                include=${ORACLE_HOME}/rdbms/public 

PROC_DIR = ./proc/           

LIBDIRS= -L$(HOME)/lib -L$(ORACLE_HOME)/lib
INCL=-I$(ORACLE_HOME)/precomp/public/  -I"../incl/" -I"../incl/proc/"
LIB= -lclntsh -lm

PC = $(ORACLE_HOME)/bin/proc
CC = g++

RM = rm -f

exec=H010_Load.V1.26.1

OBJECTS = connection.o exception.o command.o reader.o row.o readerimp.o file.o filereader.o filerow.o \
	datetime.o str.o tableschema.o tabletemp.o sqlldr.o merge.o wrapper.o partition.o main.o
	
all: $(exec) clean

$(exec): $(OBJECTS)
	$(CC) $(LIBDIRS) $(OBJECTS) $(LIB) -o $(exec)
	@mv $(exec) ~/bin/
	
connection.o: ./proc/connection.pc
	$(PC) iname=./proc/connection.pc  oname=connection.cpp MODE=ORACLE CODE=CPP  ${PROC_INCL} parse=none \
	SQLCHECK=NONE CHAR_MAP=VARCHAR2 SQLCHECK=syntax
	$(CC) -c $(INCL) connection.cpp -o connection.o
	$(RM) connection.cpp

exception.o: ./proc/exception.cpp
	$(CC) -c $(INCL) ./proc/exception.cpp -o exception.o

command.o: ./proc/command.pc
	$(PC) iname=./proc/command.pc  oname=command.cpp MODE=ORACLE CODE=CPP  ${PROC_INCL} parse=none \
	SQLCHECK=NONE CHAR_MAP=VARCHAR2 SQLCHECK=syntax 
	$(CC) -c $(INCL) command.cpp -o command.o
	$(RM) command.cpp

readerimp.o: ./proc/readerimp.pc
	$(PC) iname=./proc/readerimp.pc  oname=readerimp.cpp MODE=ORACLE CODE=CPP  ${PROC_INCL} parse=none \
	SQLCHECK=NONE CHAR_MAP=VARCHAR2 SQLCHECK=syntax 
	$(CC) -c $(INCL) readerimp.cpp -o readerimp.o
	$(RM) readerimp.cpp

reader.o: ./proc/reader.cpp
	$(CC) -c $(INCL) ./proc/reader.cpp -o reader.o

row.o: ./proc/row.cpp
	$(CC) -c $(INCL) ./proc/row.cpp -o row.o

file.o: file.cpp
	$(CC) -c $(INCL) file.cpp -o file.o

filereader.o: filereader.cpp
	$(CC) -c $(INCL) filereader.cpp -o filereader.o

filerow.o: filerow.cpp
	$(CC) -c $(INCL) filerow.cpp -o filerow.o

str.o: str.cpp
	$(CC) -c $(INCL) str.cpp -o str.o

datetime.o: datetime.cpp
	$(CC) -c $(INCL) datetime.cpp -o datetime.o

tableschema.o: tableschema.cpp
	$(CC) -c $(INCL) tableschema.cpp -o tableschema.o

tabletemp.o: tabletemp.cpp
	$(CC) -c $(INCL) tabletemp.cpp -o tabletemp.o

sqlldr.o: sqlldr.cpp
	$(CC) -c $(INCL) sqlldr.cpp -o sqlldr.o

merge.o: merge.cpp
	$(CC) -c $(INCL) merge.cpp -o merge.o

wrapper.o: wrapper.cpp
	$(CC) -c $(INCL) wrapper.cpp -o wrapper.o

partition.o: partition.cpp
	$(CC) -c $(INCL) partition.cpp -o partition.o

main.o: main.cpp
	$(CC) -c $(INCL) main.cpp -o main.o
	
clean:
	$(RM) *.o *.lis tp* proc/*.lis
